home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Games / Hugo / Library / hugofix.h < prev    next >
Text File  |  1997-04-21  |  5KB  |  301 lines

  1. !----------------------------------------------------------------------------
  2. !
  3. !       HUGOFIX Debugging Library v2.3.2 by Kent Tessman (c) 1995-1997
  4. !                     for use with Hugo Compiler v2.3
  5. !
  6. !----------------------------------------------------------------------------
  7. !
  8. !    NOTE:  These routines and the corresponding grammar table are
  9. !           automatically included by HUGOLIB.H and GRAMMAR.G if the
  10. !           DEBUG compiler flag is set.
  11. !
  12. !----------------------------------------------------------------------------
  13.  
  14. #version 2.3
  15.  
  16. #ifclear _COMPILING_HUGOLIB
  17. #message warning "HUGOFIX.H not #included; #set DEBUG instead"
  18. #endif
  19.  
  20. #ifset _COMPILING_HUGOLIB
  21.  
  22. ! BITMASKS FOR debug_flags:
  23.  
  24. global debug_flags
  25.  
  26. enumerate step *2
  27. {
  28.     D_FUSES = 1             ! fuse/daemon monitoring
  29.     D_OBJNUM                ! object numbers
  30.     D_PARSE                 ! parse monitoring
  31.     D_SCRIPTS               ! script monitoring
  32. }
  33.  
  34. routine DoHugoFix
  35. {
  36.     local i, n, place
  37.  
  38.     select word[1]
  39.     case "$", "$?"
  40.     {
  41.         "HUGOFIX DEBUGGING COMMANDS:\n\
  42.         \_    $?  - Display this help menu\n"
  43.  
  44.         "Monitoring:\n\
  45.         \_    $on - Toggle object numbers\n"
  46.  
  47.     #ifclear NO_SCRIPTS
  48.            "\_    $sc - Script monitor on/off"
  49.     #endif
  50.  
  51.     #ifclear NO_FUSES
  52.            "\_    $fd - Fuse/daemon monitor on/off"
  53.     #endif
  54.  
  55.            "\_    $pm - Parser monitoring on/off\n"
  56.  
  57.            "Object movement:\n\
  58.         \_    $mo <obj.> to <obj.> - Move object to new parent\n\
  59.         \_    $mp <obj.>           - Move player object to new 
  60.             parent\n"
  61.  
  62.         "Object testing:\n\
  63.         \_    $fo <obj.>   - Find object\n\
  64.         \_    $na <obj. #> - Print name of object number <obj.>\n\
  65.         \_    $nu <obj.>   - Print number of object <obj.>\n"
  66.         
  67.         "Other utilities:"
  68.  
  69.     #ifclear NO_FUSES
  70.            "\_    $ac <obj.> [timer] - Activate fuse (with timer) or 
  71.             daemon\n\
  72.         \_    $de <obj.>         - Deactivate fuse or daemon"
  73.     #endif
  74.  
  75.     #ifclear NO_OBJLIB
  76.            "\_    $di [obj.] - Audit directions (for room <obj.>)"
  77.     #endif
  78.  
  79.            "\_    $ot [obj.] - Print object tree (beginning with 
  80.             <obj.>)\n\
  81.         \_    $wo <val.> - Print dictionary word entry <val.>"
  82.     }
  83.  
  84.     case "$wo"
  85.     {
  86.         print "\""; object; "\""
  87.     }
  88.  
  89. #ifclear NO_SCRIPTS
  90.     case "$sc"
  91.     {
  92.         "[Script monitor";
  93.         OnorOff(D_SCRIPTS)
  94.     }
  95. #endif
  96.  
  97. #ifclear NO_FUSES
  98.     case "$fd"
  99.     {
  100.         "[Fuse/daemon monitor";
  101.         OnorOff(D_FUSES)
  102.     }
  103. #endif
  104.  
  105.     case "$fo"
  106.     {
  107.         "[Parent of obj. "; : print number object; " ("; \
  108.         object.name; "):  Obj. ";
  109.         print number (parent(object)); " ("; parent(object).name; ")]"
  110.     }
  111.     case "$mo"
  112.     {
  113.         print "[Obj. "; number object; " ("; object.name; ") "; 
  114.         print "moved to obj. "; number xobject; " ("; 
  115.         print xobject.name; ")]"
  116.         move object to xobject
  117.         object is not hidden
  118.         object is known
  119.     }
  120.     case "$mp"
  121.     {
  122.         if parent(object) ~= 0 and object is not enterable
  123.             {print "[Obj. "; number object; " ("; 
  124.             print object.name; ") is not a room object]"}
  125.         else
  126.             MovePlayer(object, false, true)
  127.     }
  128.     case "$on"
  129.     {
  130.         "[Object numbers";
  131.         OnorOff(D_OBJNUM)
  132.     }
  133.     case "$na"
  134.     {
  135.         print "\""; object.name; "\""
  136.     }
  137.     case "$nu"
  138.     {
  139.         print "[Obj. "; number object; "]"
  140.     }
  141.     case "$ot"
  142.     {
  143.         print "["; number object; "] "; object.name
  144.         list_nest = (object ~= 0)
  145.         for (i=0; i<objects; i=i+1)
  146.         {
  147.             if i ~= object and parent(i) = object
  148.                 DrawBranch(i)
  149.         }
  150.     }
  151.  
  152. #ifclear NO_FUSES
  153.     case "$ac"
  154.     {
  155.         if object.type ~= fuse and object.type ~= daemon
  156.             "Not a fuse or daemon."
  157.         else
  158.             {Activate(object)
  159.             object.timer = xobject
  160.             "Activated."}
  161.     }
  162.     case "$de"
  163.     {
  164.         if object.type ~= fuse and object.type ~= daemon
  165.             "Not a fuse or daemon."
  166.         else
  167.             {Deactivate(object)
  168.             "Deactivated."}
  169.     }
  170. #endif
  171.  
  172.     case "$pm"
  173.     {
  174.         "[Parser monitoring";
  175.         OnorOff(D_PARSE)
  176.     }
  177.  
  178. #ifclear NO_OBJLIB
  179.     case "$di"
  180.     {
  181.         if object:  place = object
  182.         else:  place = location
  183.  
  184.         print "DIRECTIONS FROM:  "; capital place.name; "\n"
  185.         for i in direction
  186.         {
  187.             print "\_ "; i.name; ":  ";
  188.             if &place.(i.dir_to)
  189.                 "(Property routine)"
  190.             else
  191.             {
  192.                 n = place.i.dir_to
  193.                 if n > 1
  194.                     print capital n.name
  195.                 elseif n = 0
  196.                 {
  197.                     if not place.cant_go
  198.                         print CThe(player); \
  199.                             " can't go that way."
  200.                 }
  201.             }
  202.         }
  203.     }
  204. #endif
  205. }
  206.  
  207. routine OnorOff
  208. {
  209.     local a
  210.     
  211.     if not (debug_flags & a)
  212.     {
  213.         print " on.]"
  214.         debug_flags = debug_flags | a
  215.     }
  216.     else
  217.     {
  218.         print " off.]"
  219.         debug_flags = debug_flags & ~a
  220.     }
  221. }
  222.  
  223. routine DrawBranch(obj)
  224. {
  225.     local i, nextobj
  226.  
  227.     for (i=1; i<=list_nest; i++)
  228.         print ". . ";
  229.     print "["; number obj; "] "; obj.name
  230.     
  231.     for nextobj in obj
  232.         {list_nest++
  233.         DrawBranch(nextobj)
  234.         list_nest--}
  235. }
  236.  
  237. replace The(obj, a)
  238. {
  239.     AssignPronoun(obj)
  240.  
  241.     if obj = player and player_person = 1 and a
  242.     {
  243.         print player.pronoun #2;
  244.         jump PrintTheObjNumber
  245.     }
  246.  
  247.     if obj.article
  248.         print "the ";
  249.     print obj.name;
  250.  
  251. :PrintTheObjNumber
  252.     if (debug_flags & D_OBJNUM)
  253.         print " ["; number obj; "]";
  254. }
  255.  
  256. replace CThe(obj)
  257. {
  258.     AssignPronoun(obj)
  259.  
  260.     if obj.article
  261.         print "The "; obj.name;
  262.     else
  263.         print capital obj.name;
  264.     if (debug_flags & D_OBJNUM)
  265.         print " ["; number obj; "]";
  266. }
  267.  
  268. replace Art(obj, a)
  269. {
  270.     AssignPronoun(obj)
  271.  
  272.     if obj = player and player_person = 1 and a
  273.     {
  274.         print player.pronoun #2;
  275.         jump PrintArtObjNumber
  276.     }
  277.  
  278.     if obj.article
  279.         print obj.article; " ";
  280.     print obj.name;
  281.  
  282. :PrintArtObjNumber
  283.     if (debug_flags & D_OBJNUM)
  284.         print " ["; number obj; "]";
  285. }
  286.  
  287. replace CArt(obj)
  288. {
  289.     AssignPronoun(obj)
  290.  
  291.     if obj.article
  292.         print capital obj.article; " "; obj.name;
  293.     else
  294.         print capital obj.name;
  295.     if (debug_flags & D_OBJNUM)
  296.         print " ["; number obj; "]";
  297. }
  298.  
  299. #endif  ! ifset _COMPILING_HUGOLIB
  300.  
  301.